@extends('app')
@include('UEditor::head')
@section('content')
<ul class="nav nav-tabs">
    <li><a href="{{ url('/admin/enterprise/jobs/index')}}">信息列表</a></li>
    <li class="active"><a href="#">信息编辑</a></li>
</ul>
<form id="jobsForm" method="post">
    <div class="panel panel-default description2 mt20">
        <div class="form-group clearfix">
            <div class="col-sm-2 control-label">职位名称：</div>
            <div class="col-sm-6">
                <input type="text" class="form-control" name="name" id="name" placeholder="职位名称" value="{{ empty($result)?'':$result->title }}">
            </div>
        </div>
        <div class="form-group clearfix">
            <div class="col-sm-2 control-label">企业名称：</div>
            <div class="col-sm-6">
                @if(empty($result))
                 <select name="company_id" class="form-control" onchange="getExaminations(this.value,'/admin/enterprise/jobs/index/exams/','examid')">
                    <option value="0">请选择企业</option>
                    @foreach($companys as $comp)
                    <option value="{{ $comp->id }}">{{ $comp->name }}</option>
                    @endforeach
                </select> 
                @else
                {{ empty($result)?:$result->company->name }}<input type="hidden" name="company_id" value="{{ empty($result)?:$result->company_id }}">
                @endif
            </div>
        </div>
        <div class="form-group clearfix">
            <div class="col-sm-2 control-label">职位类型：</div>
            <div class="col-sm-6 form-inline">
                {{--@if(!empty($result))--}}
                {{--{!! $jobsType !!}--}}
                {{--@else--}}
                {{--<select name="firstId" class="form-control" onchange="jobstype(this.value,'companyjobtype','parentId')">--}}
                    {{--<option>请选择分类</option>--}}
                    {{--@foreach($jobsType as $jobst)--}}
                    {{--<option value="{{ $jobst->cat_id }}">{{ $jobst->name }}</option>--}}
                    {{--@endforeach--}}
                {{--</select>--}}
                {{--<select name="parentId" class="form-control" onchange="jobstype(this.value,'companyjobtype','catId')" id="parentId">--}}
                    {{--<option>请选择分类</option>--}}
                {{--</select>--}}
                {{--<select  name="catId" class="form-control" id="catId">--}}
                    {{--<option>请选择分类</option>--}}
                {{--</select>--}}
                {{--@endif--}}


                <select name="firstId" id="firstId" class="form-control" onchange="jobstype(this.value,'companyjobtype','parentId')" >
                    <option>请选择分类</option>
                    @foreach($jobsType as $jobst)
                        <option value="{{$jobst->cat_id}}" @if(!empty($result)) @if($pid == $jobst->cat_id) selected @endif @endif>{{$jobst->name}}</option>
                    @endforeach
                </select>

                <select name="parentId" id="parentId" class="form-control" onchange="jobstype(this.value,'companyjobtype','catId')">
                    <option>请选择分类</option>
                    @if($blademode == 'edit')
                        @foreach($subtype as $subty)
                            <option value="{{$subty->cat_id}}" @if(!empty($result)) @if($result->category->parent_id == $subty->cat_id) selected @endif @endif>{{$subty->name}}</option>
                        @endforeach
                    @endif
                </select>

                <select name="catId" id="catId" class="form-control">
                    <option>请选择分类</option>
                        @if($blademode == 'edit' || (!empty($result)))
                            @foreach($thrtype as $thrty)
                                <option value="{{$thrty->cat_id}}" @if(!empty($result)) @if($result->cat_id == $thrty->cat_id) selected @endif @endif>{{$thrty->name}}</option>
                            @endforeach
                        @endif
                </select>

            </div>
        </div>
        <div class="form-group clearfix">
            <div class="col-sm-2 control-label">任职地区：</div>
            <div class="col-sm-6 form-inline">
                @if(!empty($result))
                {!! $areas !!}
                @else
                <select name="parentArea" class="form-control" onchange="childAreas(this.value,'areas','city')">
                    @foreach($areas as $area)
                    <option value="{{ $area->area_id }}">{{ $area->title }}</option>
                    @endforeach
                </select>
                
                <select name="area" class="form-control" id="city">
                    <option value="0">请选择分类</option>
                </select>
                @endif
            </div>
        </div>
        <div class="form-group clearfix">
            <div class="col-sm-2 control-label">薪资要求：</div>
            <div class="col-sm-6">
                <div class="form-inline">
                    <input type="number" name="salary_lower" class="form-control" value="{{empty($result)?0:$result->salary_lower}}">
                     － 
                    <input type="number" name="salary_high" class="form-control"  value="{{empty($result)?0:$result->salary_high}}">
                    <div class="help-block">单位：K，均为0的时候，为面议</div>
                </div>
            </div>
            
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">学历要求：</div>
            <div class="col-sm-6">
                <select name="degree" class="form-control">
                    @foreach($degree as $key=>$dg)
                    <option value="{{ $key }}" @if(!empty($result) && $result->degree == $key) selected @endif>{{ $dg }}</option>
                    @endforeach
                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">工作年限：</div>
            <div class="col-sm-6">
                <select name="gznx" class="form-control">
                    @foreach($gznx as $key=>$gz)
                    <option value="{{ $key }}" @if(!empty($result) &&$result->gznx == $key) selected @endif>{{ $gz }}</option>
                    @endforeach
                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">工作性质：</div>
            <div class="col-sm-6">
                <select name="gzxz" class="form-control">
                    @foreach($gzxz as $key=>$gxz)
                    <option value="{{ $key }}" @if(!empty($result) && $result->gzxz == $key) selected @endif>{{ $gxz }}</option>
                    @endforeach
                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">招聘人数:</div>
            <div class="col-sm-6">
                <input type="number" name="recruitment" class="form-control" value="{{empty($result)?0:$result->recruitment}}">
                <div class="help-block">为0则不限制</div>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">职位介绍:</div>
            <div class="col-sm-10">
                <script id="intro" name="intro"  style="width:100%;margin:0 auto;height:200px;" type="text/plain">
                </script>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">职位描述:</div>
            <div class="col-sm-10">
                <script id="description" name="description"  style="width:100%;margin:0 auto;height:200px;" type="text/plain">
                </script>
            </div>
            <div class="clear"></div>
        </div>
        @if(!empty($result))
        <div class="form-group">
            <div class="col-sm-2 control-label">审核状态：</div>
            <div class="col-sm-6">
                <select name="status" class="form-control">
                    @foreach($status as $key=>$sts)
                    <option value="{{ $key }}" @if(!empty($result) && $result->status == $key) selected @endif>{{ $sts }}</option>
                    @endforeach
                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">发布时间：</div>
            <div class="col-sm-6">
                {{ $result->published_at }}
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">更新时间：</div>
            <div class="col-sm-6">
                {{ $result->updated_at }}
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">审核时间：</div>
            <div class="col-sm-6">
                {{ $result->validated_at?:'未审核' }}
            </div>
            <div class="clear"></div>
        </div>
        @endif
        <div class="form-group">
            <div class="col-sm-2 control-label">是否开启考试：</div>
            <div class="col-sm-6">
                <label class="radio-inline">
                  <input type="radio" name="test" id="test" value="0" onclick="examinations()" @if(!empty($result)&&$result->test == 0) checked @else checked @endif > 不开启
                </label>
                <label class="radio-inline">
                  <input type="radio" name="test" id="test" value="1" onclick="examinations()" @if(!empty($result)&&$result->test == 1) checked @endif> 开启
                </label>
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group" id="examination">
            <div class="col-sm-2 control-label">试卷编号：</div>
            <div class="col-sm-6">
                <select name="examid" class="form-control" id="examid">
                    @if(!empty($result))
                    @if(count($result->company->examinations)<= 0)
                    <option value="0">暂无试卷，请先组卷</option>
                    @else
                    @foreach($result->company->examinations as $exams)
                    <option value="{{ $exams->id }}">{{ $exams->name }}</option>
                    @endforeach
                    @endif
                    @else
                    @foreach($examinations as $exams)
                    <option value="{{ $exams->id }}">{{ $exams->name }}</option>
                    @endforeach
                    @endif
                </select>
            </div>
            <div class="clear"></div>
        </div>
        {!! csrf_field() !!}
        <input type="hidden" name="jobs_id" value="{{ !empty($result)?$result->jobs_id:0 }}">
        <div class="form-inline">
            <div class="form-group col-xs-offset-1">
              <button type="button" class="btn btn-info" onclick="saveData('/admin/enterprise/jobs/index','jobsForm')">
                    <i class="icon-ok bigger-110"></i>
                    Submit
              </button>
            </div>
            <div class="form-group col-xs-offset-1">
                <button type="reset" class="btn">
                    <i class="icon-undo bigger-110"></i>
                    Reset
                </button>
            </div>
        </div>
    </div>
</form>

<script type="text/javascript">
<!--
var ue = UE.getEditor('intro');
ue.ready(function() {
	var intro = '@if(!empty($result)) {!! str_replace(array("\r\n", "\r", "\n"),"",str_replace("'",'"',$result->intro))!!} @endif';
	ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值. 
	ue.setContent(intro);   
});
var ue1 = UE.getEditor('description');
ue1.ready(function() {
	var description = '@if(!empty($result)) {!! str_replace(array("\r\n", "\r", "\n"),"",str_replace("'",'"',$result->description))!!} @endif';
	ue1.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值. 
	ue1.setContent(description);   
});

function examinations()
{
	if($('input[name=test]:checked').val() == 1)
	{
		$("#examination").show();
	}
	else
	{
		$("#examination").hide();
	}
}

$(function(){
	examinations();
});
//-->
</script>
@if(empty($result))
<script type="text/javascript">
<!--
$(function(){
	childAreas($('select[name=parentArea]').val(),'areas','city');
//	jobstype($('select[name=firstId]').val(),'companyjobtype','parentId');
});
//-->
</script>
@endif
@endsection
